package com.wcx.imitationwechatbilllist.details;

import android.content.Context;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wcx.imitationwechatbilllist.R;

import java.util.List;

import androidx.annotation.NonNull;

/**
 * @author: 魏从响
 * @date: 2025/10/24
 * @class: ListDetailsAdapter
 */
public class ListDetailsAdapter extends BaseQuickAdapter<ListDetailsBean, BaseViewHolder> {
    private final Context context;

    public ListDetailsAdapter(Context context, int itemListDetails, List<ListDetailsBean> list) {
        super(itemListDetails, list);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, ListDetailsBean listDetailsBean) {

        TextView tv_title = baseViewHolder.findView(R.id.tv_title);
        TextView tv_time = baseViewHolder.findView(R.id.tv_time);
        TextView tv_amount = baseViewHolder.findView(R.id.tv_amount);

        tv_title.setText(listDetailsBean.getTitle());
        tv_time.setText(listDetailsBean.getTime());
        tv_amount.setText(listDetailsBean.getAmount());

    }

    // 处理带payload的刷新，用于局部更新（可选但推荐）
//    @Override
//    protected void convert(@NonNull BaseViewHolder holder, ListDetailsBean item, @NonNull List<Object> payloads) {
//        if (payloads.isEmpty()) {
//            // 如果payload为空，则进行完整的绑定
//            convert(holder, item);
//        } else {
//            // 根据payloads中的信息进行局部更新
//            // 例如，如果payload是"STARLIGHT_VALUE_CHANGED"，则只更新星光值的TextView
//            for (Object payload : payloads) {
//                if (payload instanceof String && "STARLIGHT_VALUE_CHANGED".equals(payload)) {
////                    TextView tv_starlight_value = holder.findView(R.id.tv_starlight_value);
////                    tv_starlight_value.setText("");
//                }
//                // 可以添加更多的payload处理逻辑
//            }
//        }
//    }

}
